<?php

class ControllerVinDecoder extends Controller {

    public function index() {
        $this->document->title = 'VIN Decoder';

        $this->data['heading_title'] = 'VIN DEcoder';

        $this->load->model('vin/decoder');

        if (isset($this->request->post['vin'])) {
            $vin_decoded = $this->model_vin_decoder->decode_vin(strtoupper($this->request->post['vin']));
            $this->data['vin_data'] = $vin_decoded;
        }

        if (file_exists(DIR_TEMPLATE . $this->config->get('config_template') . '/template/vin/decoder.tpl')) {
            $this->template = $this->config->get('config_template') . '/template/vin/decoder.tpl';
        } else {
            $this->template = 'default/template/vin/decoder.tpl';
        }

        $this->children = array(
            'common/column_right',
            'common/column_left',
            'common/footer',
            'common/header'
        );

        $this->response->setOutput($this->render(TRUE), $this->config->get('config_compression'));
    }

}
?>